package com.vcc.service.impl;

import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.vcc.core.exception.NotFoundException;
import com.vcc.data.entity.KycSuccessCertInfo;
import com.vcc.data.mapper.KycSuccessCertInfoMapper;
import com.vcc.service.boss.response.kyc.KycSuccessCertInfoVoBoss;
import com.vcc.service.service.KycSuccessCertInfoService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class KycSuccessCertInfoServiceImpl extends ServiceImpl<KycSuccessCertInfoMapper, KycSuccessCertInfo> implements KycSuccessCertInfoService {


    @Override
    public Boolean existsByUserId(Long userId) {
        return queryChain().eq(KycSuccessCertInfo::getUserId, userId).exists();
    }

    @Override
    public KycSuccessCertInfo getByUserId(Long userId) {
        return queryChain().eq(KycSuccessCertInfo::getUserId, userId).oneOpt().orElseThrow(() -> new NotFoundException("并未提交认证"));
    }


    @Override
    public List<KycSuccessCertInfoVoBoss> listByUserId(Long userId) {
        return queryChain().eq(KycSuccessCertInfo::getUserId, userId).listAs(KycSuccessCertInfoVoBoss.class);
    }
}
